package src.com.servlet;

import src.com.data.User;
import src.com.service.MyService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
public class Signup extends HttpServlet{
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html");
        MyService myService = new MyService();
        String userName = req.getParameter("name");
        String password = req.getParameter("password");
        User user = new User();
        user.setName(userName);
        user.setPassword(password);
        System.out.println("请求方式" + req.getMethod());
        boolean result = myService.sign_up(user);
        PrintWriter out = resp.getWriter();
        out.print(result);
        out.flush();
        out.close();
    }
}

